import request from '@/utils/request'

/**获取我的商品数量 */
export const goodsCount = () =>
  request({
    url: '/api/commodity/count',
    method: 'get',
  })
/**获取我的商品访问量 */
export const goodsRead = () =>
  request({
    url: '/api/commodity/read',
    method: 'get',
  })
/**获取我的商品 */
export const goodsMy = ({ qw, classifyid, page, size, recycle, all }) =>
  request({
    url: '/api/commodity/my',
    method: 'get',
    params: { qw, classifyid, page, size, recycle, all },
  })
/**从id获取信息商品 */
export const goodsFromid = ({ id }) =>
  request({
    url: '/api/commodity/fromid',
    method: 'get',
    params: {
      id,
    },
  })
/**新增商品 */
export const goodsAdd = ({ name, price, stock, classifyid, brandid, tags, image, specification }) =>
  request({
    url: '/api/commodity/add',
    method: 'post',
    data: {
      name,
      price,
      stock,
      classifyid,
      brandid,
      tags,
      image,
      specification,
    },
  })
/**修改商品 */
export const goodsModify = ({ id, name, price, stock, classifyid, brandid, tags, image, specification, publish }) =>
  request({
    url: '/api/commodity/modify',
    method: 'post',
    data: {
      id,
      name,
      price,
      stock,
      classifyid,
      brandid,
      tags,
      image,
      specification,
      publish,
    },
  })
/**删除商品 */
export const goodsDel = ({ id }) =>
  request({
    url: '/api/commodity/del',
    method: 'post',
    data: {
      id,
    },
  })
/**恢复商品 */
export const goodsRecycle = ({ id }) =>
  request({
    url: '/api/commodity/recycle',
    method: 'post',
    data: {
      id,
    },
  })
/**批量删除商品 */
export const goodsDels = ({ ids }) =>
  request({
    url: '/api/commodity/dels',
    method: 'post',
    data: {
      ids,
    },
  })
